package com.betterjr.modules.application.entity;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.modules.application.data.AmsMenuResourceRelationConstantCollections;

/**
 * 菜单资源中间表
 * @ClassName: AmsMenuResourceRelation 
 * @Description: 菜单资源中间表 
 * @author xuyp
 * @date 2017年11月17日 下午5:40:49 
 *
 */
@Access(AccessType.FIELD)
@Entity
@Table(name = "t_ams_menu_resource")
public class AmsMenuResourceRelation implements BetterjrEntity {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -4094003349456218515L;

    /**
     * 流水号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "流水号", comments = "流水号")
    private Long id;

    /**
     * 菜单id
     */
    @Column(name = "n_menuid", columnDefinition = "INTEGER")
    @MetaData(value = "菜单id", comments = "菜单id")
    private Long menuId;

    /**
     * 资源id
     */
    @Column(name = "n_resourceid", columnDefinition = "INTEGER")
    @MetaData(value = "资源id", comments = "资源id")
    private Long resourceId;

    /**
     * 状态 1 生效  9 失效
     */
    @Column(name = "c_businStatus", columnDefinition = "VARCHAR")
    @MetaData(value = "状态 1 生效  9 失效", comments = "状态 1 生效  9 失效")
    private String businStatus;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getMenuId() {
        return menuId;
    }

    public void setMenuId(Long menuId) {
        this.menuId = menuId;
    }

    public Long getResourceId() {
        return resourceId;
    }

    public void setResourceId(Long resourceId) {
        this.resourceId = resourceId;
    }

    public String getBusinStatus() {
        return businStatus;
    }

    public void setBusinStatus(String businStatus) {
        this.businStatus = businStatus;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((businStatus == null) ? 0 : businStatus.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((menuId == null) ? 0 : menuId.hashCode());
        result = prime * result + ((resourceId == null) ? 0 : resourceId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        AmsMenuResourceRelation other = (AmsMenuResourceRelation) obj;
        if (businStatus == null) {
            if (other.businStatus != null) return false;
        } else if (!businStatus.equals(other.businStatus)) return false;
        if (id == null) {
            if (other.id != null) return false;
        } else if (!id.equals(other.id)) return false;
        if (menuId == null) {
            if (other.menuId != null) return false;
        } else if (!menuId.equals(other.menuId)) return false;
        if (resourceId == null) {
            if (other.resourceId != null) return false;
        } else if (!resourceId.equals(other.resourceId)) return false;
        return true;
    }

    @Override
    public String toString() {
        return "AmsMenuResourceRelation [id=" + id + ", menuId=" + menuId + ", resourceId=" + resourceId
                + ", businStatus=" + businStatus + "]";
    }

    public void saveAddValue() {

        this.setBusinStatus(AmsMenuResourceRelationConstantCollections.AMSMENURESOURCERELATION_BUSINSTATUS_EFFECTIVE);
        this.setId(SerialGenerator.getLongValue("AmsMenuResourceRelation.id"));

    }

}
